﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 刘颜红销售项目管理
{
    public class SearchResultEnumerator : System.Collections.IEnumerator 
    {
        public SearchResultEnumerator()
        {
        }

        private string _Condition = null;

        public string Condition
        {
            get
            {
                return _Condition; 
            }
        }

        public bool SetCondition(string condition)
        {
            if (string.Compare(_Condition, condition , this.IngoreCase) != 0)
            {
                _Condition = condition ;
                _List = null;
                myEnumerator = null;
                return true;
            }
            else
            {
                return false;
            }
        }

        public void Clear()
        {
            _Condition = null;
            _List = null;
        }

        private bool _IngoreCase = true;

        public bool IngoreCase
        {
            get
            {
                return _IngoreCase; 
            }
            set
            {
                _IngoreCase = value; 
            }
        }

        private System.Collections.ArrayList _List = null;

        private System.Collections.IEnumerator myEnumerator = null;
        private System.Collections.IEnumerator Enumerator
        {
            get
            {
                if (myEnumerator == null && _List != null)
                {
                    myEnumerator = _List.GetEnumerator();
                    myEnumerator.Reset();
                }
                return myEnumerator;
            }
        }

        public void AddResult(object result)
        {
            if (_List == null)
            {
                _List = new System.Collections.ArrayList();
            }
            _List.Add(result);
        }

        public void Remove(object result)
        {
            if (_List != null)
            {
                _List.Remove(result);
            }
        }

        public int Count
        {
            get
            {
                if (_List == null)
                    return 0;
                else
                    return _List.Count;
            }
        }
        public object Current
        {
            get
            {
                if (this.Enumerator == null)
                    return null;
                else
                    return this.Enumerator.Current;
            }
        }

        public bool MoveNext()
        {
            if (this.Enumerator != null)
            {
                return this.Enumerator.MoveNext();
            }
            else
            {
                return false;
            }
        }

        public void Reset()
        {
            if (this.Enumerator != null)
            {
                this.Enumerator.Reset();
            }
        }
    }
}
